﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HaumDisplay
{
    public partial class HaumImageInfo : Form
    {
        public HaumImageInfo()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="image"></param>
        /// <param name="location"></param>
        public HaumImageInfo(HaumImage image, Point location)
        {
            InitializeComponent();
            this.Location = location;
            if (image == null)
            {
                return;
            }
            listView.Items[0].SubItems.Add($"{image.bmp.Width * image.bmp.Height} Pixel");
            listView.Items[1].SubItems.Add(image.bmp.Width.ToString());
            listView.Items[2].SubItems.Add(image.bmp.Height.ToString());
            listView.Items[3].SubItems.Add(image.pixelFormat.ToString()); //文件名
            listView.Items[4].SubItems.Add(image.bitDepth.ToString());
            listView.Items[5].SubItems.Add(image.fileName); //文件名
            if (image.imageFormat == null)
            {
                listView.Items[6].SubItems.Add("未知类型"); //文件类型
            }
            else
            {
                listView.Items[6].SubItems.Add(image.imageFormat.ToString()); //文件类型
            }
            listView.Items[7].SubItems.Add(image.fullPath); //文件路径
            listView.Items[8].SubItems.Add(image.time.ToString("yyyy/MM/dd HH:mm:ss")); //时间
            listView.Items[9].SubItems.Add(image.size.ToString("0.00") + " MB"); //大小

        }

        /// <summary>
        /// 键盘按下事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listView_KeyDown(object sender, KeyEventArgs e)
        {
            //判断选中的项是否大于1 将第一个选中项的值复制到文本
            if (listView.SelectedItems.Count > 0 && e.Control && e.KeyCode == Keys.C ) {
                if (listView.SelectedItems[0].SubItems.Count > 1)
                {
                    Clipboard.SetText(listView.SelectedItems[0].SubItems[1].Text);
                    e.Handled = true;
                }
            }
        }
    }
}
